home *** CD-ROM | disk | FTP | other *** search
Text File | 1993-08-06 | 3.1 KB | 98 lines | [TEXT/KAHL] |
- //************************************************************************
- //
- // A standard environment
- // I am accustomed to
-
- #pragma once
- #ifndef _myenv_h
-
- #define _myenv_h
- #pragma interface
-
- // Strings of symbols
- // They may be used as a delimiting lines
- extern const char _Minuses [];
- extern const char _Asteriscs [];
- extern const char _Equals [];
-
- // Print an error message at stderr and abort
- volatile void _error(
- const char * message, // Message to be printed
- ... // Additional args like in printf()
- );
- // Set a custom fuction that would perform abort
- // nil means set up the standard abort function
- void set_abort_function(const volatile void (*custom_abort)(void));
-
- // Print a message at stderr
- void message(
- const char * text, // Message to be printed
- ... // Additional args to printf
- );
-
- class ErrHandler
- {
- Boolean raise_hell; // Raise the hell in case of error?
- Boolean was_error; // Has an error sneaked in whilst we're lenient?
-
- public:
- ErrHandler(void);
- ~ErrHandler(void) {}
- void error(const char * message,...);
- void lenient(void); // Be lenient
- Boolean was_ok(void); // Have we failed?
- };
-
- //------------------------------------------------------------------------
- // Verify the assertion
-
-
- #define assert(ex) \
- (void)((ex) ? 1 : \
- (_error("Failed assertion " #ex " at line %ld of `%s'.", \
- __LINE__, __FILE__), 0))
- #define assertval(ex) assert(ex)
-
- #define assure(expr,message) \
- if (expr) ; \
- else _error("%s at line %ld of '%s'.",message,__LINE__, __FILE__);
-
- // Execute the function 'ex' and make sure
- // it return noErr
- #define do_well(ex) \
- { OSErr err = (ex); if( err != noErr ) \
- _error("Failed call " #ex " with error %ld at line %ld of `%s'.", \
- err, __LINE__, __FILE__); }
-
- //------------------------------------------------------------------------
- // Notification posting
- // The set of functions below let a (backgound) application to post
- // synchronous or asynchronous notification messages to the user.
- // Synchronous posting means that function does not return until the
- // notification message is displayed and the user dismisses it.
- // In asynchronous mode, the posting function returns as soon as the
- // message is queued into the notification queue (but not yet displayed!).
- //
-
- void notify_and_wait(const char * messg,...);
- void notify(const char * messg,...);
-
- //------------------------------------------------------------------------
- // Sound playing on errors
-
- void set_error_sound(Str255 sound_name);
-
- //------------------------------------------------------------------------
- // Macintosh System Utilities
-
- void Initialize_MAC(void);
- void sleep(const int nticks); // Generous suspension for a specified no. of ticks
-
- // Launch an application and have it handle the
- // specified file, as if the file were
- // "double-clicked"
- void open_selection(const char * full_path_name);
-
-
- #endif
-